import requests

url = 'https://www.baidu.com'

headers = {
    'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Mobile Safari/537.36'
}
# timeout 设置连接时间，参数为秒 ， 时间到请求超时报错
r = requests.get(url=url, headers=headers, timeout=1)










